﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace HowItWentDown
{
    abstract class Enemy:Obj
    {
        public float health = 25, attack  = 10;
        float colval = 1;

        public Enemy(Game1 doc, float newX, float newY, float newZ, Texture2D tex)
            : base(doc, newX, newY, newZ, tex)
        {
            stationary = false;
            floating = false;
            collision = true;
            pickable = false;
            climbable = false;
        }
        public override void Update()
        {
            if (colval > 0.5f)
            {
                PickUp pu = Collides<PickUp>();
                if (pu != null)
                {
                    takeDamage(5);
                    pu.velocity *= -0.5f;
                }
            }
            colval += (1 - colval) * 0.05f;
            Color = MyMath.Between(Color.Red, Color.White, colval);
            base.Update();
        }
        //attack from monster, seeing as the player could theorectically dodge, 
        //the target is the position at time of attack
        public void makeAttack(Vector3 target)
        {
            //if obj with health is in range, deal damage.
        }

        //move to position
        public void move(Vector3 target)
        {
            //if obj with health is in range, deal damage.
        }

        // take damage from sources
        public void takeDamage(int i)
        {
            if (health > 0)
            {
                colval = 0;
                health -= i;
                if (health <= 0)
                {
                    health = 0;
                    remove();
                }
            }
        }
    }
}
